Skip to content

backend: cmd: Add unit test for buildHeadlampCFG configuration mapping#6121

Open
CygnusMaximillian wants to merge 1 commit into
kubernetes-sigs:mainfrom
CygnusMaximillian:backend/server_config_test
Open

backend: cmd: Add unit test for buildHeadlampCFG configuration mapping#6121
CygnusMaximillian wants to merge 1 commit into
kubernetes-sigs:mainfrom
CygnusMaximillian:backend/server_config_test

Conversation

@CygnusMaximillian

Copy link
Copy Markdown
Contributor

Summary

The buildHeadlampCFG function in backend/cmd/server.go maps raw configuration inputs into the HeadlampCFG struct. This crucial mapping logic currently has no test coverage. Introducing an isolated unit test for this function will ensure configuration flags map correctly.

PR description

Introduces test coverage for buildHeadlampCFG in the cmd package to ensure configuration fields map securely and correctly.

Changes:

Added backend/cmd/server_config_test.go with TestBuildHeadlampCFG Steps to

Test:

  • Navigate to the backend directory.
  • Run npm run backend:test and ensure all tests pass.
image

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: CygnusMaximillian
Once this PR has been reviewed and has the lgtm label, please assign ashu8912 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot requested review from sniok and yolossn June 20, 2026 17:26
@kubernetes-prow kubernetes-prow Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 20, 2026
@illume illume requested a review from Copilot June 22, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial unit test coverage for buildHeadlampCFG (backend/cmd), which maps config.Config values into headlampconfig.HeadlampCFG.

Changes:

  • Adds backend/cmd/server_config_test.go with TestBuildHeadlampCFG to validate basic config-to-runtime mapping.

Comment thread backend/cmd/server_config_test.go
Comment thread backend/cmd/server_config_test.go

@illume illume left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR.

The open review comments from Copilot still need attention — can you have a look? Once addressed, please mark them as resolved.

Signed-off-by: CygnusMaximillian <dprajjwal11@gmail.com>
@CygnusMaximillian CygnusMaximillian force-pushed the backend/server_config_test branch from 4d26a60 to 70da609 Compare June 23, 2026 09:03
@kubernetes-prow kubernetes-prow Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 23, 2026
@CygnusMaximillian

Copy link
Copy Markdown
Contributor Author

@illume I have resolved the changes can you please take a look

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment on lines +27 to +41
func TestBuildHeadlampCFG(t *testing.T) {
conf := &config.Config{
Port: 4444,
InsecureSsl: true,
ProxyURLs: "http://proxy1,http://proxy2",
}
store := kubeconfig.NewContextStore()

headlampCFG := buildHeadlampCFG(conf, store)

assert.Equal(t, uint(4444), headlampCFG.Port)
assert.True(t, headlampCFG.Insecure)
assert.Equal(t, []string{"http://proxy1", "http://proxy2"}, headlampCFG.ProxyURLs)
assert.Equal(t, store, headlampCFG.KubeConfigStore)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants